//==============================================================================
#include "CApp.h"

//==============================================================================
bool CApp::OnInit() {
	if(SDL_Init(SDL_INIT_EVERYTHING) < 0) {
		return false;
	}

	//redirect STDOUT and STDERR back to console

	SDL_WM_SetCaption("Bottleneck", "Bottleneck");

	SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1 );

	if((Surf_Display = SDL_SetVideoMode(w_width, w_height, 32, 	 SDL_HWSURFACE| SDL_GL_DOUBLEBUFFER |SDL_OPENGL)) == NULL) {
		return false;
	}


	Surf_Test = NULL;
	Surf_Display = NULL;
	rotatex =0.0 ;
	lastTime = SDL_GetTicks();
	frames =0;
	Running = true;
	fpsText.str("FPS: 0");


	font = new FTGLPixmapFont("../font/arial.ttf");
	if(font->Error())
		return -1;

	// Set the font size and render a small text.
	font->FaceSize(16);
	fpsCounterPosition = new FTPoint(0,w_height-font->LineHeight());

	// Satunnaislukugeneraattorin alustus
	srand((unsigned int) time(0));

	const GLclampf red = 20.0f/255.0f;
	const GLclampf green = 150.0f/255.0f;
	const GLclampf blue = 255.0f/255.0f;

	glClearColor(red, green, blue, 0);
	glViewport(0, 0, w_width, w_height);
	glEnable(GL_DEPTH_TEST);
	glEnable(GL_NORMALIZE);





	/*
	 *Initializing the fluid parameters
	 *
	 */
	showDensity = true;
	for(int i = 0; i< SIZE;i++)
	{
			
		density[i] = 0.0f;
		density_previous[i] = 0.0f;
		u[i] = 0.0f;
		v[i] = 0.0f;
		u_previous[i] = 0.0f;
		v_previous[i] = 0.0f;

	}

	force = 5.0f;
	source = 10.0f;
	omx = 0;
	omy = 0;
	//viscosity =0.0000005f;
	//diffusionRate =0.0005f;
	viscosity =0.005f;
	diffusionRate =0.0001f;
	gravity = false;
	//Sets the correct drawing mode for 3d.
	disable2d();
	RenderMode = GL_QUADS;

	return true;
}



//==============================================================================
